Hệ thống quản lý nguồn nhân lực Dự án năm cuối trong c#
1 Public Class Frm_PerformanceAll
2
3 Dim flag As Integer = 0
4 Dim monthName As String = String.Empty
5
6 Private Function monthPerformance(ByRef monthName As String) As DataTable
7
8 Dim query = "Select E.employee_id , E.full_name , " & monthName
9 query = query & " From Employee_Performance_Table Ept"
10 query = query & " Inner Join Employee E On E.employee_id = Ept.employee_id"
11 query = query & " Inner Join Performance P On P.performance_id = Ept.performance_id"
12
13 Return getDataTable(query)
14
15 End Function
16
17 Private Sub cmboxMonths_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmboxMonths.SelectedIndexChanged
18
19 If cmboxMonths.Text.Equals("January") Then
20
21 dgvPerformance.DataSource = monthPerformance("perf_january")
22
23 ElseIf cmboxMonths.Text.Equals("Feburary") Then
24
25 dgvPerformance.DataSource = monthPerformance("perf_feburary")
26
27 ElseIf cmboxMonths.Text.Equals("March") Then
28
29 dgvPerformance.DataSource = monthPerformance("perf_march")
30
31 ElseIf cmboxMonths.Text.Equals("April") Then
32
33 dgvPerformance.DataSource = monthPerformance("perf_april")
34
35 ElseIf cmboxMonths.Text.Equals("May") Then
36
37 dgvPerformance.DataSource = monthPerformance("perf_may")
38
39 ElseIf cmboxMonths.Text.Equals("June") Then
40
41 dgvPerformance.DataSource = monthPerformance("perf_june")
42
43 ElseIf cmboxMonths.Text.Equals("July") Then
44
45 dgvPerformance.DataSource = monthPerformance("perf_july")
46
47 ElseIf cmboxMonths.Text.Equals("August") Then
48
49 dgvPerformance.DataSource = monthPerformance("perf_august")
50
51 ElseIf cmboxMonths.Text.Equals("September") Then
52
53 dgvPerformance.DataSource = monthPerformance("perf_september")
54
55 ElseIf cmboxMonths.Text.Equals("October") Then
56
57 dgvPerformance.DataSource = monthPerformance("perf_october")
58
59 ElseIf cmboxMonths.Text.Equals("November") Then
60
61 dgvPerformance.DataSource = monthPerformance("perf_november")
62
63 ElseIf cmboxMonths.Text.Equals("December") Then
64
65 dgvPerformance.DataSource = monthPerformance("perf_december")
66
67 End If
68
69 End Sub
70
71 Private Sub Frm_PerformanceAll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
72
73 Me.Size = New Size(605, 582)
74 Me.lblPerf.Location = New Point(123, 6)
75
76 End Sub
77
78 Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
79
80 If flag = 0 Then
81 Me.btnUpdate.Text = "<< Update Performance"
82 Me.Size = New Size(1068, 582)
83 Me.lblPerf.Location = New Point(382, 6)
84 flag = 1
85 ElseIf flag = 1 Then
86 Me.btnUpdate.Text = "Update Performance >>"
87 Me.Size = New Size(605, 582)
88 Me.lblPerf.Location = New Point(123, 6)
89 flag = 0
90 End If
91
92 End Sub
93
94 Private Function employeePerformance(ByVal employeeID As Integer, ByVal monthName As String) As DataTable
95
96 Dim query = "Select E.employee_id , E.full_name, P.performance_id, P." & monthName
97 query = query & " From Employee_Performance_Table Ept"
98 query = query & " Inner Join Employee E on E.employee_id = Ept.employee_id"
99 query = query & " Inner Join Performance P on P.performance_id = Ept.performance_id"
100 query = query & " Where E.employee_id ='" & employeeID & "'"
101
102 Return getDataTable(query)
103
104 End Function
105
106 Private Sub cmboxMonths2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmboxMonths2.SelectedIndexChanged
107
108 If cmboxMonths2.Text.Equals("January") Then
109
110 monthName = "perf_january"
111
112 ElseIf cmboxMonths2.Text.Equals("Feburary") Then
113
114 monthName = "perf_feburary"
115
116 ElseIf cmboxMonths2.Text.Equals("March") Then
117
118 monthName = "perf_march"
119
120 ElseIf cmboxMonths2.Text.Equals("April") Then
121
122 monthName = "perf_april"
123
124 ElseIf cmboxMonths2.Text.Equals("May") Then
125
126 monthName = "perf_may"
127
128 ElseIf cmboxMonths2.Text.Equals("June") Then
129
130 monthName = "perf_june"
131
132 ElseIf cmboxMonths2.Text.Equals("July") Then
133
134 monthName = "perf_july"
135
136 ElseIf cmboxMonths2.Text.Equals("August") Then
137
138 monthName = "perf_august"
139
140 ElseIf cmboxMonths2.Text.Equals("September") Then
141
142 monthName = "perf_september"
143
144 ElseIf cmboxMonths2.Text.Equals("October") Then
145
146 monthName = "perf_october"
147
148 ElseIf cmboxMonths2.Text.Equals("November") Then
149
150 monthName = "perf_november"
151
152 ElseIf cmboxMonths2.Text.Equals("December") Then
153
154 monthName = "perf_december"
155
156 End If
157
158 End Sub
159
160 Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
161
162 Try
163
164 Dim dt As DataTable = employeePerformance(Convert.ToInt32(txtID.Text), monthName)
165
166 For Each row As DataRow In dt.Rows
167
168 dgvEmployee.Rows.Add()
169 dgvEmployee.Rows(dgvEmployee.RowCount - 1).Cells("PerfID").Value = row("performance_id")
170 dgvEmployee.Rows(dgvEmployee.RowCount - 1).Cells("EmpID").Value = row("employee_id")
171 dgvEmployee.Rows(dgvEmployee.RowCount - 1).Cells("EmpName").Value = row("full_name")
172 dgvEmployee.Rows(dgvEmployee.RowCount - 1).Cells("PerfMonth").Value = row(monthName)
173 dgvEmployee.Rows(dgvEmployee.RowCount - 1).Cells("FromDB").Value = True
174 dgvEmployee.Rows(dgvEmployee.RowCount - 1).DefaultCellStyle.ForeColor = Color.Black
175
176 Next
177
178 Catch ex As Exception
179
180 MsgBox(ex.Message, MsgBoxStyle.Critical)
181
182 End Try
183
184 End Sub
185
186 Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
187
188 Try
189
190 Dim query = "Update Performance set " & monthName & " = " & dgvEmployee.SelectedRows(0).Cells("PerfMonth").Value & " Where performance_id = " & dgvEmployee.SelectedRows(0).Cells("PerfID").Value & ""
191 executeQuery(query)
192
193 Catch ex As Exception
194
195 MsgBox(ex.Message, MsgBoxStyle.Critical)
196
197 End Try
198 End Sub
199
200 End Class